#include "input.hpp"
#include "content/data_provider.hpp"
#include "imgui.h"
#include "imgui_stdlib.h"

void input_item::update_data (bindable_base *data)
{
    if (value_)
        value_->attach (data);
}

void input_item::init_content (const xml_node &node)
{
    ui_control::init_content (node);
    value_ = create_data (node.attribute ("value").as_string (), data_category::std_string | data_category::c_string | data_category::number);
}

void input_item::draw_self ()
{
    std::string value = value_->get_std_string ();
    if (ImGui::InputText ("##Value", &value))
    {
        value_->set_std_string (value);
    }
}
